package com.diankangwo.service.impl;

import cn.beecloud.bean.TransferData;
import com.diankangwo.dao.OrderRefundDAO;
import com.diankangwo.dao.RefundMoneyDAO;
import com.diankangwo.domain.RefundMoney;
import com.diankangwo.service.RefundMoneyService;
import com.diankangwo.util.PageSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 退费记录业务实现类
 * 
 * @author xiaoyu
 *
 */
@Service(value = "refundMoneyService")
public class RefundMoneyServiceImpl implements RefundMoneyService {

	@Autowired
	private RefundMoneyDAO rmd;// 依赖注入退款记录dao
	
	@Autowired
	private OrderRefundDAO orderRefundDAO;// 依赖注入退款操作dao

	/**
	 * 保存或更新
	 */
	@Override
	public void saveOrUpdate(RefundMoney t) {
		rmd.insertOrUpdateRefunMoney(t);
	}

	/**
	 * 按ID删除记录
	 */
	@Override
	public void deleteById(Integer id) {
		rmd.deleteRefunMoneyById(id);
	}

	/**
	 * 查询所有
	 */
	@Override
	public List<RefundMoney> findAll() {
		// 创建对象集合，用户存储数据
		List<RefundMoney> rmList = new ArrayList<RefundMoney>();
		// 执行查询操作，得到数据
		rmList = rmd.findAll();
		return rmList;
	}

	/**
	 * 条件查询
	 */
	@Override
	public List<RefundMoney> findByCondition(RefundMoney re) {
		// 创建对象集合，用户存储数据
		List<RefundMoney> rmList = new ArrayList<RefundMoney>();
		// 执行查询操作，得到数据
		rmList = rmd.findByCondition(re);
		return rmList;
	}

	/**
	 * 添加退费记录
	 */
	@Override
	public boolean insertOrUpdateRefunMoney(RefundMoney re) {
		return rmd.insertOrUpdateRefunMoney(re);
	}

	/**
	 * 删除退费记录
	 */
	@Override
	public boolean deleteRefunMoney(RefundMoney re) {
		return rmd.deleteRefunMoney(re);
	}

	/**
	 * 分页查询退费记录
	 */
	@Override
	public PageSupport<RefundMoney> findPagination(int pageNo, int pageSize) {
		return null;
	}

	/**
	 * 退款
	 */
	public String BCRefundParamter(String billNo, String refundNo, Integer refundFee, Map<String, Object> optional) {
		return orderRefundDAO.BCRefundParamter(billNo, refundNo, refundFee, optional);
	}

	/**
	 * ALi批量退款
	 */
	public String batchPayment(String batchNo, List<TransferData> list, String accountName) {
		return orderRefundDAO.batchPayment(batchNo, list, accountName);
	}

	/**
	 * 按id查询信息
	 */
	@Override
	public RefundMoney findById(int id) {
		return rmd.findById(id);
	}

}
